/**
 * Created by kang on 2016/12/19
 */
'use strict';

app.factory('LHDataService', ['Utils',function (Utils) {
	var lists = [{
		id : "1",
		imgUrl:"img/max.png",
		name:"皇冠1号",
		description:"如果无法简洁的表达您的想法，只能说明你还不够了解它",
		date:"2017/01/03",
		support : "45",
		criticism : "23"
	},{
		id : "2",
		imgUrl:"img/mike.png",
		name:"皇冠2号",
		description:"如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它",
		date:"2017/01/03",
		support : "45",
		criticism : "23"
	},{
		id : "3",
		imgUrl:"img/mike.png",
		name:"皇冠3号",
		description:"如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它",
		date:"2017/01/03",
		support : "45",
		criticism : "23"
	},{
		id : "4",
		imgUrl:"img/mike.png",
		name:"皇冠4号",
		description:"如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它",
		date:"2017/01/03",
		support : "45",
		criticism : "23"
	},{
		id : "5",
		imgUrl:"img/mike.png",
		name:"皇冠5号",
		description:"如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它",
		date:"2017/01/03",
		support : "45",
		criticism : "23"
	},{
		id : "6",
		imgUrl:"img/mike.png",
		name:"皇冠6号",
		description:"如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它",
		date:"2017/01/03",
		support : "45",
		criticism : "23"
	},{
		id : "7",
		imgUrl:"img/mike.png",
		name:"皇冠7号",
		description:"如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它",
		date:"2017/01/03",
		support : "45",
		criticism : "23"
	},{
		id : "8",
		imgUrl:"img/mike.png",
		name:"皇冠8号",
		description:"如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它",
		date:"2017/01/03",
		support : "45",
		criticism : "23"
	},{
		id : "9",
		imgUrl:"img/mike.png",
		name:"皇冠9号",
		description:"如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它,如果无法简洁的表达您的想法，只能说明你还不够了解它",
		date:"2017/01/03",
		support : "45",
		criticism : "23"
	
	}];
	var centeridx = 0;
	var centercss = {"width":200, "height":100, "top":25, "zIndex":1};
	var backcss = {"width":300, "height":150, "top":0, "zIndex":2};
	//定义一个数组 映射五颗星星的位置和图片
	var starArray = [{"idx":1},{"idx":2},{"idx":3},{"idx":4},{"idx":5}];
	
	return {
		alllists:function(){
			//console.log(lists);
			return lists;
		},
		getlist:function(id){
			for (var i = 0; i < lists.length; i++) {
		        if (lists[i].id === id) {
		        	centeridx = i;
		            return lists[i];
		        }
		    }
		    return null;
		},
		getStarArray:function(level){
		},
		initpage:function(){
			setPosition();
		}
		
	};
	
	function setPosition(){
		console.log("setPosition");
		var $box = document.getElementById("parentbox");
		var $oUl = $box.getElementsByTagName("ul")[0];
		var $aLiarr = $box.getElementsByTagName("li");
		/*console.log($box);
		console.log($oUl);
		console.log($aLiarr);*/
		
		for (var i = 0; i < $aLiarr.length; i++) {
	        if(i==centeridx){
	        	$aLiarr[i].style["display"] = "block";
	        	setCss($aLiarr[i],centercss)
	        }else if(i==centeridx+1){
	        	if(centeridx!=$aLiarr.length){
	        		$aLiarr[i].style["display"] = "block";
	        		setCss($aLiarr[i],backcss);
	        	}
	        }else if(i==centeridx-1){
	        	if(centeridx!=0){
	        		$aLiarr[i].style["display"] = "block";
	        		setCss($aLiarr[i],backcss);
	        	}
	        }else{
	        	$aLiarr[i].style["display"] = "none";
	        	setCss($aLiarr[i],backcss);
	        }
	    }
	}
	
	function setCss($dom,css){
		console.log($dom);
		$dom.style["width"] = css["width"];
		$dom.style["height"] = css["width"];
		$dom.style["top"] = css["width"];
		$dom.style["zIndex"] = css["width"];
	}
	
}]);
